<%@page import="data.GeoData"%>
<%@page import="models.UserModel"%>
<%@page import="data.UserData"%>
<%@page import="data.DealData"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%@page import="models.OrderModel"%>
<%@page import="java.util.Locale"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="models.DealModel"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	OrderModel order = (OrderModel)request.getAttribute("order");
	UserModel user = (UserModel)request.getAttribute("user");
	GeoData geoData = new GeoData();
	DealData dealData = new DealData(); 
	DealModel deal = dealData.getById(order.getDealId());
	NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
%>
<jsp:include page="/layouts/header.jsp">
	<jsp:param name="language" value="1" />	
</jsp:include>	 
        <div id="content_inner">
            	<div id="productDetailInfo" class="clearafter">
            		<%
            			if(order!=null){            				
            				SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");            				       				
            		%>
                	<div class="left">                    	
                    	<div id="ordersInfo">
							<h1>Thông tin đơn hàng</h1>
                            <div class="content-right">
                            	<a href="/don-hang/in/<%=order.getOrderId() %>" class="button blue">In đơn hàng</a>
                                <a href="/don-hang/in/<%=order.getOrderId() %>" class="button blue">Hỗ trợ đơn hàng</a>
                            </div>
                            <div class="orderStatus">                            	
                            	<p><strong>Đơn hàng:</strong> 	<%=order.getOrderId() %></p>
                                <p><strong>Ngày:</strong> 	<%=dateFormat.format(order.getOrderDate())%></p>
								<p><strong>Trạng thái:</strong> 	Mới đặt </p>
                            </div>
                            <div>
                                <h3>Thông tin deal</h3>
                                <table cellpadding="0" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th width="60%">Deal</th>
                                            <th>Đơn giá</th>
                                            <th>Số lượng</th>
                                            <th>Thành tiền</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr valign="top">
                                            <td align="left">
                                                <a href="/<%=deal.getDealId()%>/<%=deal.getAlias()%>.html"><strong><%=deal.getName() %></strong></a>
                                                <br />
                                                <p class="sku">Code: <%=order.getOrderId() %></p>
                                            </td>
                                            <td><%=nf.format(order.getUnitPrice()) %>&nbsp;VNĐ</td>
                                            <td><%=order.getQuantity() %></td>
                                            <td><strong><%=nf.format(order.getUnitPrice()*order.getQuantity()) %>&nbsp;VNĐ</strong></td>
                                        </tr>                                    
                                    </tbody>
                                </table>
                            </div>
                            <div>
                            	<h3>Tóm tắt</h3>
                                <div class="orderSummary">
                                	<p><strong>Hình thức thanh toán:</strong>  	Thanh toán trực tiếp (Nhân viên giao hàng thu tiền)</p>
                                    <p><strong>Thành tiền:</strong>  	<%=nf.format(order.getUnitPrice()*order.getQuantity()) %> VNĐ</p>
                                    <p><strong>Tổng cộng:</strong>  	<strong><%=nf.format(order.getUnitPrice()*order.getQuantity()) %> VNĐ</strong></p>
                                    <p><strong>Ghi chú khách hàng:</strong>  	<%=order.getNote() %></p>
                                </div>
                            </div>
                            <div>
                            	<h3>Thông tin khách hàng</h3>
                                <div class="customerInfo">
                                	<h4>Thông tin liên lạc</h4>
                                    <p><strong>Email:</strong>		<%=order.getUsername() %></p>
                                    <br />
                                    <h4>Địa chỉ giao hàng</h4>
                                    <p><strong>Họ tên:</strong>		<%=order.getShipName() %></p>
                                    <p><strong>Địa chỉ:</strong>	<%=order.getShipAddress() %>, <%=order.getShipStreet() %>, <%=geoData.getGeo(order.getShipWard()).getName() %>, <%=geoData.getGeo(order.getShipDistrict()).getName() %>, <%=geoData.getGeo(order.getShipCity()).getName() %></p>
                                    <p><strong>Điện thoại:</strong>		<%=user.getPhone() %></p>
                                </div>
                            </div>                       
                        </div>                        
                    </div>
                    <%
            			}
                    %>
                    <div class="right rightSideBar">
                   		<jsp:include page="/elements/right_menu.jsp"/>
                   	</div>					   					
                </div>
            </div>
<jsp:include page="/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>